extends KinematicBody2D

export (int) var run_speed = 150
export (int) var jump_speed = -400
export (int) var gravity = 1200
var jumping = false
var velocity = Vector2()

# Need to find out how to best pull variables from other scripts :v
var plant_area = Global.in_plant_area #this seems to be the solution? but a true variable doesn't affect it so idk

func get_input():
	velocity.x = 0
	var right = Input.is_action_pressed('ui_right')
	var left = Input.is_action_pressed('ui_left')
	var jump = Input.is_action_just_pressed('ui_up')

	if jump and !jumping :
		jumping = true
		velocity.y += jump_speed 
	if right:
		velocity.x += run_speed
	if left:
		velocity.x -= run_speed
		
	if Input.is_action_just_pressed("interact") and Global.in_plant_area : 
		print('growth') #standin for proper code to grows

func _physics_process(delta):
	get_input()
	velocity.y += gravity * delta * .85
	if  is_on_floor():
		jumping = false
	velocity = move_and_slide(velocity, Vector2(0, -1))
